import java.util.ArrayList;

public class Queue {

	private int stockId;
	private ArrayList<ActiveOrder> buyQueue;
	private ArrayList<ActiveOrder> sellQueue;
	private ArrayList<ActiveOrder> marketQueue;

	private double currentStockPrice;

	public int getStockId() {
		return stockId;
	}

	public void setStockId(int stockId) {
		this.stockId = stockId;
	}

	public ArrayList<ActiveOrder> getBuyQueue() {
		return buyQueue;
	}

	public void setBuyQueue(ArrayList<ActiveOrder> buyQueue) {
		this.buyQueue = buyQueue;
	}

	public ArrayList<ActiveOrder> getSellQueue() {
		return sellQueue;
	}

	public void setSellQueue(ArrayList<ActiveOrder> sellQueue) {
		this.sellQueue = sellQueue;
	}

	public double getCurrentStockPrice() {
		return currentStockPrice;
	}

	public void setCurrentStockPrice(double currentStockPrice) {
		this.currentStockPrice = currentStockPrice;
	}

	public ArrayList<ActiveOrder> getMarketQueue() {
		return marketQueue;
	}

	public void setMarketQueue(ArrayList<ActiveOrder> marketQueue) {
		this.marketQueue = marketQueue;
	}

	public ArrayList<ActiveOrder> getActiveOrdersFromQueue(
			ArrayList<ActiveOrder> queue) {
		ArrayList<ActiveOrder> activeOrders = new ArrayList<ActiveOrder>();
		for (ActiveOrder activeOrder : queue) {
			if ((activeOrder.order.getOrderState()).equals(activeOrder.order
					.getActiveState())) {
				activeOrders.add(activeOrder);
			}
		}
		return activeOrders;
	}

	public Queue(int stockId, double stockPrice) {
		this.stockId = stockId;
		this.currentStockPrice = stockPrice;
		buyQueue = new ArrayList<ActiveOrder>();
		sellQueue = new ArrayList<ActiveOrder>();
		marketQueue = new ArrayList<ActiveOrder>();
	}

	public void add(ActiveOrder activeOrder) {
		if ((OrderCategory.BUY).equals(activeOrder.getOrder()
				.getOrderCategory())) {
			buyQueue.add(activeOrder);
		} else if ((OrderCategory.SELL).equals(activeOrder.getOrder()
				.getOrderCategory())) {
			sellQueue.add(activeOrder);
		}
	}

	public void addInMarketQueue(ActiveOrder order) {
		marketQueue.add(order);
	}

}
